import { Switch,Redirect,Route } from 'react-router-dom'
import IndexPage from './views/index'
import Page404 from './views/404'
const types = ['all','good','share','ask']


function App() {
  return (
    <div className="wrap">
      <Switch>
        <Route path='/index/:t?/:p?'
          render={({match})=>{
            const {t="all",p="1"} = match.params;
            if(types.includes(t) && parseInt(p)+"" === p){
              return <IndexPage />
            }
            return <Redirect to="/404" />
          }}
        />
        <Route path="/404" component={Page404} />
        <Redirect path='/' to="/index" exact />
        <Redirect to="/404" />
      </Switch>
    </div>
  );
}

export default App;
